{% extends "eventyay_common/auth/base.html" %}
{% load bootstrap3 %}
{% load i18n %}
{% load static %}
{% load urlreplace %}
{% load append_next_url %}
{% block content %}
    <form class="form-signin" action="" method="post">
        <div id="login-form" class="collapse">
            {% if backends|length > 1 %}
                <ul class="nav nav-pills">
                    {% for b in backends %}
                        {% if b.visible %}
                            <li class="{% if backend.identifier == b.identifier %}active{% endif %}">
                                <a href="{% if b.url %}{{ b.url }}{% else %}?{% url_replace request "backend" b.identifier %}{% endif %}">
                                    {{ b.verbose_name }}
                                </a>
                            </li>
                        {% endif %}
                    {% endfor %}
                </ul>
                <br>
            {% endif %}
            {% csrf_token %}
            {% bootstrap_form form %}
            <div class="form-group buttons">
                {% if backend.login_form_fields %}
                <button type="submit" class="btn btn-primary btn-block">
                    {% translate "Log in" %}
                </button>
                {% endif %}
                {% if backend.url %}
                    <a href="{{ backend.url }}" class="btn btn-primary btn-block">
                        {{ backend.verbose_name }}
                    </a>
                {% endif %}
                {% if backend.identifier == "native" %}
                    {% if can_reset %}
                        <a href="{% url "eventyay_common:auth.forgot" %}" class="btn btn-link btn-block">
                            {% translate "Lost password?" %}
                        </a>
                    {% endif %}
                    {% if can_register %}
                        <a href='{% url "eventyay_common:auth.register" %}{% append_next request.GET.next %}' class="btn btn-link btn-block">
                            {% translate "Register" %}
                        </a>
                    {% endif %}
                {% endif %}
            </div>
        </div>
        <div class="form-group buttons">
            <button type="button" id="toggle-login" class="btn btn-primary btn-block" data-toggle="collapse" data-target="#login-form">
                {% translate "Login with Email" %}
            </button>
            {% if login_providers %}
                {% for provider, settings in login_providers.items %}
                    {% if settings.state %}
                        <a href='{% url "plugins:socialauth:social.oauth.login" provider %}{% append_next request.GET.next %}' 
                           data-method="post" class="btn btn-primary btn-block">
                            {% with provider|capfirst as provider_capitalized %}
                                {% blocktranslate %}Login with {{ provider_capitalized }}{% endblocktranslate %}
                            {% endwith %}
                        </a>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </div>
    </form>
{% endblock %}
